package cn.iocoder.yudao.module.bpm.message.redis.custom.processTask;


import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
import cn.iocoder.yudao.module.bpm.message.handle.ProcessTaskMessageHandle;
import cn.iocoder.yudao.module.bpm.message.redis.dto.RedisBpmProcessTaskCreatedMessage;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;

@RequiredArgsConstructor
@Log4j2
public class RedisProcessTaskCreatedCustom extends AbstractRedisStreamMessageListener<RedisBpmProcessTaskCreatedMessage> {

    private final ProcessTaskMessageHandle processTaskMessageHandle;

    @Override
    public void onMessage(RedisBpmProcessTaskCreatedMessage message) {
        try {
            log.info("消费消息：{}", message);
            processTaskMessageHandle.onProcessInstanceTaskCreatedMsg(message.getBpmProcessMessage());
        } catch (Exception e) {
            log.error("MQ消费失败", e);
            throw new RuntimeException(e.getMessage());
        }
    }

}
